#ifndef __PAGE_MANAGER_H__
#define __PAGE_MANAGER_H__

#include "lvgl.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ani_common.h"
#ifdef __cplusplus
extern "C" {
#endif



#define MAX_PAGE_NUM    20

    enum PAGEINDEX {
        MAIN_ROOT = 0,
        MAIN_PAGE,
        WEATHER_RAGE,
        WEATHER_RAGE1,
        START_PAGE,
        NONE_PAGE,
    };

    typedef struct lv_page_map {
        int key;
        lv_obj_t* obj;
    }lv_page_map_t;

    typedef struct lv_page_ops {
        void (*create)(lv_obj_t* obj);
        void (*destroy)(lv_obj_t* obj);
        void (*entry)(lv_obj_t* obj);
        void (*exit)(lv_obj_t *obj);
    }lv_page_ops_t;

    typedef struct lv_page_node
    {
        lv_page_map_t       page;
        lv_page_ops_t       ops;
        struct lv_page_node * pri;
        struct lv_page_node * next;
    }lv_page_t;


    lv_obj_t* lv_page_manager_create(lv_obj_t* parent);
    lv_obj_t* lv_page_create(lv_obj_t* parent, int page_key);
    lv_page_t* lv_get_page(int page_key);

    void lv_page_manager_add_node(lv_page_t* page_node);
    void lv_page_manager_remove_node(int page_key);
    void lv_page_bind_exit(int page_key, void(*page_exit));
    void lv_page_bind_entry(int page_key, void(*page_entry));
    void lv_page_bind_destroy(int page_key, void(*page_destroy));
    void lv_page_bind_create(int page_key, void(*page_create));
    void lv_page_start_up(int current_key,int page_key);
    void lv_page_load_main(int key);
    void lv_page_load(int last_key, int key);

    void lv_page_entry_default(lv_obj_t* obj);
    void lv_page_exit_default(lv_obj_t* obj);

    void lv_page_show();
    void lv_main_page_start_up(int page_key);
#ifdef __cplusplus
} /* extern "C" */
#endif

#endif
